docs: Document naga WGSL bundling and module composition capabilities#2
docs: Document naga WGSL bundling and module composition capabilities#2
Conversation
Co-authored-by: bytesandwich <1048685+bytesandwich@users.noreply.github.com>
…ect function path Co-authored-by: bytesandwich <1048685+bytesandwich@users.noreply.github.com>
|
@copilot Do you think we could change naga to do two additional passes import/export and link, and also provide a source mapping? How wild we go about it? Please explain |
Yes, adding import/export and linking to naga is technically feasible but would be a significant undertaking. Here's how it could be approached: Architecture for Import/Export/Link1. Import/Export Pass (Pre-parse or AST level)Add new directive handling in export fn myFunction() { ... }
import "module_path" { myFunction, MyType }This would:
2. Linking Pass (IR level)Create a new
The trickiest part is handle remapping—naga's arena-based IR uses 3. Source MappingNaga already has
Effort Estimate
Alternative: Expose Parser APIA lighter approach (as discussed in #6250) would be exposing naga's lexer/parser as a public API, letting tools like naga_oil handle composition at the source level before naga parsing. This is essentially what naga_oil does today but with regex-based preprocessing. |
Co-authored-by: bytesandwich <1048685+bytesandwich@users.noreply.github.com>
Connections
Investigation requested to understand naga's facilities for shader modularity, bundling, and test harness separation.
Description
Investigated naga's WGSL frontend for import/include/linking capabilities. Key findings:
Naga does NOT provide:
pp_rs, WGSL does not)Available extension points:
f16,dual_source_blending,clip_distances,wgpu_mesh_shader,wgpu_ray_queryreadonly_and_readwrite_storage_textures,packed_4x8_integer_dot_product,pointer_composite_accessExternal solutions exist:
#importsyntaxAdded
docs/naga-bundling-capabilities.mddocumenting:--compact)Spaninfrastructure (~2-3 weeks effort)Testing
Documentation only. No code changes.
Squash or Rebase?
Squash
Checklist
cargo fmt.taplo format.cargo clippy --tests. If applicable, add:--target wasm32-unknown-unknowncargo xtask testto run tests.CHANGELOG.mdentry.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.